/* main.vala
 *
 * Copyright (C) 2008  Frederik 'playya' Sdun
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Author:
 * 	Frederik 'playya' Sdun <Frederik.Sdun@gmail.com>
 */

using GLib;
//using Gee;
using Rob;
using E;

namespace Rob
{
	namespace Rules
	{
		public class Calendar: Rob.Rules.Rule
		{
			//private string _name;
			//private string _title;
			private bool[] types;
			construct
			{
				types = new bool[ 5 ];
				for(int i = 0; i <5; i++)
					types[ i ] = false;
				_type = "calendar";
			}
			~Time()
			{
				stdout.printf("Dtor\n");
			}	
		
			public /*override*/ bool check()
			{
				return false;
			}
			public /*override*/ bool load(GLib.KeyFile kf, string name)
			{
				try
				{
					this._name = name;
					this._title = kf.get_string(name, "title");	
					types[ (int) E.CalComponentVType.NO_TYPE ] = kf.get_boolean(name, "no_type");
					types[ (int) E.CalComponentVType.EVENT ] = kf.get_boolean(name, "event");
					types[ (int) E.CalComponentVType.TODO ] = kf.get_boolean(name, "todo");
					types[ (int) E.CalComponentVType.JOURNAL  ] = kf.get_boolean(name, "journal");
					types[ (int) E.CalComponentVType.FREEBUSY ] = kf.get_boolean(name, "fressbusy");
					types[ (int) E.CalComponentVType.TIMEZONE ] = kf.get_boolean(name, "timezone");
				}

				catch( GLib.KeyFileError kfe)
				{
					return false;
				}
				return true;
			}
			public /*override*/ bool save(ref GLib.KeyFile kf)
			{
				base.save(ref kf);
				kf.set_boolean( _name, "no_type", types[ (int)  E.CalComponentVType.NO_TYPE ]);
				kf.set_boolean( _name, "event", types[ (int)  E.CalComponentVType.EVENT ]);
				kf.set_boolean( _name, "todo", types[ (int)  E.CalComponentVType.TODO]);
				kf.set_boolean( _name, "journal", types[ (int) E.CalComponentVType.JOURNAL ]);
				kf.set_boolean( _name,"freebusy", types[ (int) E.CalComponentVType.FREEBUSY ]);
				kf.set_boolean( _name,"timezone", types[ (int) E.CalComponentVType.TIMEZONE ]);

				return true;	
			}
			public /*override*/ void run()
			{

			}

		}
		public GLib.Type get_type_of_calendar()
		{
			return typeof(Rob.Rules.Calendar);
		}
		
	}
}
